/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hu.sqlexpr;

/**
 *
 * @author trekan
 */
public class SqlExpr {

    private Visitor visitor;
    private Statement statement;

    public SqlExpr(String syntax) throws SyntaxException {
        if ("oracle".equals(syntax)) {
            visitor = new OracleVisitor();
        } else {
            throw new SyntaxException("Syntax '" + syntax +"' is not supported!");
        }
    }
    
    public Select select(String select) {
        final Select sel = new Select(select);
        this.statement = sel;
        return sel;
    }
    
    public Result result() throws SyntaxException {
        statement.accept(visitor);
        return new Result(visitor.getSql(), visitor.getBindings());
    }
}
